﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using ITAP.Shprosses.Modelling.Components;
//using ITAP.Shprosses.Modelling.Components.Actions;
//using System.Drawing;
//using ITAP.Shprosses.Editor;
//using System.Windows.Forms;
//using ITAP.Shprosses.Properties;

//namespace ITAP.Shprosses.Operations
//{
//    public class OperationAlignSelectedComponentPositionsRelativeToModel : IOperation
//    {
//        private List<Type> typesOfComponents;

//        public OperationAlignSelectedComponentPositionsRelativeToModel(Type[] typesOfComponents)
//        {
//            this.typesOfComponents = new List<Type>(typesOfComponents);
//        }

//        #region IOperation Members

//        public string Name
//        {
//            get { return "Выравнивание соединителей относительно модели"; }
//        }

//        public void Execute(ModelControl modelControl)
//        {
//            AlignComponentsRelativeToModelForm alignForm = new AlignComponentsRelativeToModelForm();
//            if (alignForm.ShowDialog() == DialogResult.OK)
//            {
//                RectangleF boundingBox = new RectangleF();
//                switch (alignForm.AlignRelative)
//                {
//                    case AlignRelative.ToModelSize:
//                        boundingBox = ((ModelCell)modelControl.ModelContainer.ActiveCell).Model.BoundingBox;
//                        break;
//                    case AlignRelative.ToInnerModelSize:
//                        Model model = ((ModelCell)modelControl.ModelContainer.ActiveCell).Model;
//                        boundingBox = model.BoundingBox;
//                        boundingBox = new RectangleF(boundingBox.X + (float)model.SpacerWidth, boundingBox.Y + (float)model.SpacerWidth, boundingBox.Width - 2 * (float)model.SpacerWidth, boundingBox.Height - 2 * (float)model.SpacerWidth);
//                        break;
//                    case AlignRelative.ToModelCellSize:
//                        boundingBox = ((ModelCell)modelControl.ModelContainer.ActiveCell).BoundingBox;
//                        break;
//                }

//                foreach (IComponent selectedComponent in modelControl.ModelContainer.SelectedComponentsStack)
//                    if (typesOfComponents.Contains(selectedComponent.GetType()))
//                    {
//                        IComponentAction alignAction = new ActionAlignComponentsPositionsRelativeToModel(modelControl, typesOfComponents.ToArray(), alignForm.Align, boundingBox);
//                        alignAction.Action(selectedComponent);
//                        break;
//                    }
//            }
//        }

//        #endregion

//        #region IOperation Members


//        public OperationGroup OperationGroup
//        {
//            get { return OperationGroup.ShprossConnectorOperation; }
//        }

//        #endregion

//        #region IOperation Members


//        public Image Thumbnail
//        {
//            get { return Resources.AlignShprossConnectorsByModel.ToBitmap(); }
//        }

//        #endregion

//        #region IOperation Members


//        public bool CanUndo
//        {
//            get { return true; }
//        }

//        #endregion
//    }
//}
